/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


package multiplayer;

import Entities.Scene;
import Visitor.IVisitor;
import Visitor.PaintVisitor;
import java.awt.Graphics;


public class RendererOtrosClientes extends Thread implements Renderer{

    private Scene scene;
    private PanelPrincipal panelPrincipal;
    private Graphics g;

    public RendererOtrosClientes(PanelPrincipal panelPrincipal) {
        this.panelPrincipal = panelPrincipal;
    }
    
    @Override
    public void execute() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void run(){
        g = panelPrincipal.getImage().getGraphics();//
        while(true){
            try{
                g.clearRect(0, 0, 400, 300);
                IVisitor paintVisitor = new PaintVisitor(g);
                if(scene != null){
                    scene.accept(paintVisitor);
                }
                    panelPrincipal.repaint();
                Thread.sleep(5);
            } catch(Exception ex){
                System.out.println("RendererOtrosClientes::run()");
            }
        }
    }

    public void setScene(Scene scene) {
        this.scene = scene;
    }
    
}
